package com.koron.css2.baseConfig.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.baseConfig.bean.GarbageTypeBean;
import com.koron.css2.baseConfig.mapper.GarbageTypeMapper;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.util.Constant;
import com.koron.util.JsonUtils;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

public class GarbageTypeAdd implements ServerInterface {

	@Override
	public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
		// TODO Auto-generated method stub
		try {
			GarbageTypeBean bean = JsonUtils.objectToPojo(req.getData(), GarbageTypeBean.class);
			GarbageTypeMapper mapper = factory.getMapper(GarbageTypeMapper.class);
			bean.setCreateInfo(userInfo);
			mapper.add(bean);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			logger.error("非法参数", e);
			return MessageBean.create(Constant.ILLEGAL_PARAMETER, "非法参数", void.class);
		}
		return MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "操作成功", void.class);
	}

}
